package it.com;

import java.util.Random;
import java.util.Scanner;

public class DeadCycle {
    public static void main(String[] args) {
        //猜数字，指定随机数字在1-100之间，并给出猜了多少次
        int i = new Random().nextInt(100) + 1;//随机数在1-100之间
        //System.out.println(i);
        Scanner scanner = new Scanner(System.in);
        int count = 1;//用户猜的次数

        while (true) {
            System.out.println("请输入你要猜的数字");
            int num = scanner.nextInt();

            if (num > i) {
                System.out.println("你猜的数字过大");
                count++;
            } else if (num < i) {
                System.out.println("你猜的数字过小");
                count++;
            } else {
                System.out.println("恭喜你答对了，共用了" + count + "次数");
                break;
            }
        }


    }
}
